<template>
  <div>
    <div class="node_container">
      <div>
        <img src="./a.png" alt="" />
      </div>
      <div class="div_one">
        <input type="text" />
      </div>
      <div class="div_two">
        <ul>
          <li>首页</li>
          <li>新手入门</li>
          <li>API</li>
          <li>关于</li>
          <li>注册</li>
          <li>登录</li>
        </ul>
      </div>
    </div>
    <div class="node_header">
      <ul>
        <li @click="change1">全部</li>
        <li @click="change2">精华</li>
        <li @click="change3">分享</li>
        <li>问答</li>
        <li>招聘</li>
        <li>客户端测试</li>
      </ul>
    </div>
    <div class="node_footer">
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <div class="node_footer_tab">
            <div
              class="node_tab_one"
              v-for="(item, index) in coplist"
              :key="index"
            >
              <div class="node_img">
                <img :src="item.author.avatar_url" alt="" />
              </div>
            </div>
          </div>
        </van-list>
      </van-pull-refresh>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      coplist: [],
      active: 1,
      refreshing: false,
      loading: false,
      finished: false,
    };
  },
  mounted() {
    this.$axios("/list.json").then((res) => {
      console.log(res);
      this.list = res.data.data;
      this.coplist = res.data.data;
      console.log(this.list);
    });
  },
  methods: {
    change1() {
      // console.log(1);
      this.coplist = this.list;
    },
    change2() {
      this.coplist = [];
      this.list.forEach((element) => {
        if (element.tab === "share") {
          this.coplist.push(element);
          // console.log(element);
        }
      });
      this.coplist = this.coplist;
      console.log(this.coplist);
    },
    change3() {
      this.coplist = [];
      this.list.forEach((element) => {
        if (element.tab === "ask") {
          this.coplist.push(element);
          // console.log(element);
        }
      });
      this.coplist = this.coplist;
      console.log(this.coplist);
    },
     onRefresh(){
      //下拉刷新
      console.log("refreshing", this.refreshing);
      this.finished=false
      setTimeout(()=>{
            this.refreshing = false;

      },3000)
  },
  onLoad(){
      //上拉加载
      
  }
  },
 
};
</script>
<style lang="scss">
.node_container {
  width: 100%;
  height: 16vh;
  background-color: #444444;
  box-sizing: border-box;
  padding: 3px 10px;
  .div_one {
    input {
      width: 56vw;
      height: 3.3vh;
      border-radius: 50px;
      background-color: #888888;
      border: none;
      outline: none;
      display: inline-flex;
    }
  }
  .div_two {
    width: 100%;
    height: 5vh;
    ul {
      width: 100%;
      height: 100%;
      list-style: none;
      display: inline-flex;
      justify-content: flex-start;
      align-items: center;
      li {
        width: 16%;
        // margin-left: 1vw;
        font-size: 12px;

        color: gainsboro;
      }
    }
  }
}
.node_header {
  width: 100%;
  height: 8vh;
  background-color: gainsboro;
  padding-top: 2vh;
  box-sizing: border-box;
 
  ul {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: inline-flex;
    justify-content: center;
    padding: 0 10px;
  
    li {
      width: 16%;
      // margin-left: 1vw;
      height: 100%;
      font-size: 12px;
    }
    li:hover {
      color: limegreen;
    }
  }
}
.node_footer {
  width: 100%;
  height: 76vh;
     overflow: scroll;
  .node_footer_tab {
    width: 100%;
     
    .node_tab_one {
      width: 100%;
      height: 10vh;
      background-color: lightslategrey;
      margin: 5px 0;
      .node_img {
        width: 20%;
        height: 100%;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>